﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XingAPICSharp.Query;

namespace XingAPICSharp
{
    public partial class XingAPIForm : Form
    {

        protected SessionCtrl m_Session;
        protected QueryCtrl m_Query;
        /*
         * 사용가능 주소 
Hts.etrade.co.kr
Prism.etrade.co.kr    (Prism IDC 전용)
Kt.etrade.co.kr          (KT IDC 전용)
사용가능 포트 : 20001, 20020, 80, 8080
         */
        public XingAPIForm()
        {
            InitializeComponent();
            m_Session = new SessionCtrl();
            m_Query = new QueryCtrl();
            m_Query.ptForm = this;
            m_Session.ptForm = this;
            m_Session.m_Session.ConnectServer("demo.etrade.co.kr", 20001);
            m_Session.m_Session.Login("obst", "22l5j8h", "toeic1004", (int)XA_SESSIONLib.XA_SERVER_TYPE.XA_SIMUL_SERVER, true);
            //m_Session.m_Session.ConnectServer("Hts.etrade.co.kr", 20001);
            //m_Session.m_Session.Login("obst", "2l5j8h", "toeic1004", (int)XA_SESSIONLib.XA_SERVER_TYPE.XA_REAL_SERVER, true);
        }

        ~XingAPIForm()
        {

        }
        /*
        private void btnLogin_Click(object sender, EventArgs e)
        {

            //m_Session.m_Session.ConnectServer("Kt.etrade.co.kr", 20001);
            m_Session.m_Session.ConnectServer("demo.etrade.co.kr", 20001);
            m_Session.m_Session.Login(textBox1.Text, textBox2.Text, textBox3.Text, (int)XA_SESSIONLib.XA_SERVER_TYPE.XA_SIMUL_SERVER, true);
        }
    */

        private void startBtn_Click(object sender, EventArgs e)
        {
            VolumeCtrl volume = new VolumeCtrl("\\res\\t1452.res");
            volume.setForm(this);
            volume.getVolume("");
            //NowPriceCtrl nPrice = new NowPriceCtrl("\\res\\t1101.res");
            //nPrice.setForm(this);
            //nPrice.getPrice("000660");

            //VolumeCtrl m_VolumeCtrl = new VolumeCtrl(this);
            //m_VolumeCtrl.getVolume(" ");
            /*
            resultlog.Text = "send protocol!\r\n";
            m_Query.m_Query.SetFieldData("t1452InBlock", "gubun", 0, "0");
            m_Query.m_Query.SetFieldData("t1452InBlock", "jnilgubun", 0, "0");
            m_Query.m_Query.SetFieldData("t1452InBlock", "idx", 0, " ");
            m_Query.m_Query.Request(false);
             
            /*
            for (int i = 1; i < 100; i++)
            {
                if (i < 10)
                {
                    resultlog.Text += "0000" + Convert.ToString(i) + "0\r\n";
                    //m_Query.m_Query.SetFieldData("t1101InBlock", "shcode", 0, "0000" + Convert.ToString(i) + "0");
                }
                else if (i >= 10 && i < 100)
                {
                    resultlog.Text += "000" + Convert.ToString(i) + "0\r\n";
                    //m_Query.m_Query.SetFieldData("t1101InBlock", "shcode", 0, "000" + Convert.ToString(i) + "0");
                }
                //m_Query.m_Query.Request(true);
            }
            /*
            m_Query.m_Query.SetFieldData("t1101InBlock", "shcode", 0, "016360");
            m_Query.m_Query.Request(true);
            m_Query.m_Query.SetFieldData("t1101InBlock", "shcode", 0, "000660");
            m_Query.m_Query.Request(true);
            m_Query.m_Query.SetFieldData("t1101InBlock", "shcode", 0, "066270");
            m_Query.m_Query.Request(true);
             */
        }
    }
}
